<?php 
	$name=$_POST["name"];
	$password=$_POST["password"];
	$checkpassword=$_POST["checkpassword"];
	$email=$_POST["email"];
	$con = mysql_connect("127.0.0.1","ace","clotshabby");
	$isinsql=false;
	if (!$con)
	{ 
		die('Could not connect: '.mysql_error());
	}
	else{
		if(mysql_select_db("gsync", $con)){
			$query = "SELECT * FROM usr_info";
			$result = mysql_query($query,$con);
			while ($row=mysql_fetch_row($result)) {
				if(0 == strcmp($row[0],$name)){
					echo "the username \" $name \" has been used!";
					$isinsql=true;
					break;
				};
			}

			$sql="insert into usr_info  (usr_name,usr_pwd,usr_email,first_time) values('$name','$password','$email',0)";
			if(false == $isinsql){
				if(mysql_query($sql,$con)){
					echo "Registration succeed！";
				}
			}
		}
		
	}
	
?>
